package leetcode.code1006;

import leetcode.helper.MaxDebug;

public class Solution extends S1006 {

	@Override
	public int clumsy(int n) {
		int ans = 0;
		int stack = n;
		int p = 0;
		int cur = 0;
		while (--n > 0) {
			if ((cur = (p++ % 4)) == 2) {
				ans += stack;
				stack = n;
			} else if (cur == 3) {
				ans += stack;
				stack = -n;
			} else if (cur == 0) {
				stack *= n;
			} else if (cur == 1) {
				stack /= n;
			}
		}
		return ans + stack;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		MaxDebug.debug14(so);
	}

}
